<!DOCTYPE html>

<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->

<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->

<!--[if !IE]><!-->

<html lang="en" class="no-js">

<!--<![endif]-->

<!-- BEGIN HEAD -->

<head>
    
    <include file="Inc/basic_css"/>

    <include file="Inc/basic_js"/>

    <import type="js" basepath="__JS__" file="AjaxFileUpload,imgpre,admin" />

    <import type="js" basepath="__PLUGIN__" file="ueditor.ueditor#config,ueditor.ueditor#all#min,ueditor.lang.zh-cn.zh-cn" />

    <link rel="stylesheet" type="text/css" href="__PLUGIN__/bootstrap-datepicker/css/datepicker.css" />

    <script type="text/javascript" src="__PLUGIN__/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="__LAYUI__/layui.all.js"></script>
    <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=XBYBZ-MEPKU-RFLVA-BXEXT-BGGHH-A2BZ4"></script>

</head>
<style>
#container{
    width:100%;
    height:300px;
}
</style>

<!-- END HEAD -->

<!-- BEGIN BODY -->

<body class="page-header-fixed">

<!-- BEGIN HEADER -->

<include file="Inc/head"/>

<!-- END HEADER -->

<div class="clearfix"></div>

<!-- BEGIN CONTAINER -->

<div class="page-container">

    <!-- BEGIN SIDEBAR -->

    <include file="Inc/left"/>

    <!-- END SIDEBAR -->

    <!-- BEGIN PAGE -->

    <div class="page-content">



        <!-- BEGIN STYLE CUSTOMIZER -->

        <include file="Inc/theme"/>

        <!-- END BEGIN STYLE CUSTOMIZER -->

        <!-- BEGIN PAGE HEADER-->

        <div class="row">

            <div class="col-md-12">

                <!-- BEGIN PAGE TITLE & BREADCRUMB-->

                <h3 class="page-title">

                    {$cfg.title}<if condition="$order.id gt 0 ">协助下单<else />协助下单</if> <small></small>

                </h3>

                <ul class="page-breadcrumb breadcrumb">

                    <li><i class="fa fa-home"></i><a href="{:U('Index/index')}">首页</a> <i class="fa fa-angle-right"></i></li>

                    <li><a href="#">协助下单</a><i class="fa fa-angle-right"></i></li>

                    <li><a href="#">{$cfg.title}<if condition="$order.id gt 0 ">修改信息<else />订单管理</if></a></li>

                </ul>                   <!-- END PAGE TITLE & BREADCRUMB-->

            </div>

        </div>

        <!-- END PAGE HEADER-->

        <!-- BEGIN PAGE CONTENT-->

        <div class="row">

            <div class="col-md-12">

                <!-- BEGIN EXAMPLE TABLE PORTLET-->

                <div class="portlet">

                    <form class="form-horizontal" action="{:U('Order/help_save')}" id="submit_form" method="Post">

                        <input type="hidden" name="id" value="{$order.id}" />
                        <input type="hidden" name="member_id" value="{$member_id}" />
                        <input type="hidden" name="order_no" value="{$order.order_no}" />
                        <input type="hidden" name="order_no_small" value="{$order.order_no_small}" />

                        <input type="hidden" name="back_url" value="{$back_url}" />

                        <div class="portlet-body form">

                            <!-- BEGIN FORM-->

                        <div class="form-body">
                            <div class="portlet box blue">
                                    <div class="portlet-title">
                                        <div class="caption"><i class="fa fa-gift"></i>订单信息</div>
                                        <div class="tools">
                                            <a href="javascript:;" class="collapse"></a>
                                            <a href="#portlet-config" data-toggle="modal" class="config"></a>
                                            <a href="javascript:;" class="reload"></a>
                                            <a href="javascript:;" class="remove"></a>
                                        </div>
                                    </div>
                                    <div class="portlet-body">
                                        <div class="table-responsive">
                                            <table class="table table-bordered table-hover">
                                                <thead>
                                                <tr>
                                                    <th>预付款订单号</th>
                                                    <th>订单状态</th>
                                                    <th>下单时间</th>
                                                    <th>预约时间</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <tr>
                                                    <td  class="active">{$order_no}</td>
                                                    <input type="hidden" name="order_no" value='{$order_no}'>
                                                    <td>
                                                        <select name="status">
                                                            <foreach name='statusArr' item='sta'>
                                                                <option value="{$key}" >{$sta.status}</option>
                                                            </foreach>
                                                        </select>
                                                    </td>
                                                    <td><input type="text" id="addtime" name="addtime" value=''  autocomplete="off"></td>
                                                    <td> <input type="text" id='booktime' name="booktime" value=''  autocomplete="off"></td>
                                                </tr>
                                                <tr>
                                                    <th>尾款订单号</th>
                                                    <th>联系电话</th>
                                                    <th>出发地</th>
                                                    <th>目的地</th>

                                                </tr>
                                                <tr>
                                                    <td  class="active">{$order_no_small}</td>
                                                    <input type="hidden" name="order_no_small" value='{$order_no_small}'>
                                                    <td  ><input type="text" name="tel" value=''></td>
                                                    <td>
                                                        <input type="text" name="departure" id='departure' class="departure" value='' list='departurelist' autocomplete="off" onchange="inputSelect()">
                                                        <datalist id="departurelist"></datalist>
                                                    </td>
                                                    <td><input type="text" name="arrival" id='arrival' class='arrival' list='arrivallist' value='' autocomplete="off" οnchange="inputSelect()" onchange="ainputSelect()">
                                                        <datalist id="arrivallist"></datalist>
                                                    </td>
                                                    
                                                </tr>
                                                <tr>
                                                    <th>搬家项目</th>
                                                    <th>搬出楼层</th>
                                                    <th>搬入楼层</th>
                                                    <th>车型</th>
                                                    <!-- <th colspan="2">项目费用总计</th> -->
                                                </tr>

                                                <tr>
                                                    <td  class="active">
                                                        {$productInfo.product_title}
                                                        <select name="product_id">
                                                            <foreach name='productList' item='pro'>
                                                                <option value="{$pro.id}">{$pro.title}</option>
                                                            </foreach>
                                                        </select>
                                                    </td>
                                                    <td  class="active">
                                                        <!-- {$productInfo.floor_from} -->
                                                        <!-- <PHP>var_dump($floor_cost);</PHP> -->
                                                        <select name="floor_from" id='floor_from' onchange="from_change()">
                                                            <foreach name='floor_cost' item='item'>
                                                                <option value="{$key}" price='{$item.price}'>{$item.title}</option>
                                                            </foreach>
                                                        </select>
                                                    </td>
                                                    <td  class="active">
                                                        <!-- {$productInfo.floor_to} -->
                                                        <select name="floor_to" id='floor_to' onchange="to_change()">
                                                            <foreach name='floor_cost' item='item'>
                                                                <option value="{$key}" price='{$item.price}'>{$item.title}</option>
                                                            </foreach>
                                                        </select>
                                                    </td>
                                                    <td  class="active">
                                                        <!-- {$cartypeInfo.cartype_title} -->
                                                         <select name="cartype_id">
                                                            <foreach name='cartypeList' item='ca'>
                                                                <option value="{$ca.id}">{$ca.title}</option>
                                                            </foreach>
                                                        </select>
                                                    </td>
                                                    <!-- <td  class="warning" colspan="2"> <input type="text" name="productInfo_price" value='{$productInfo.price}'></td> -->
                                                </tr>
                                                <tr>
                                                    <th>用户备注</th>
                                                    <td colspan="4"><input type="text" name="remark" value="{$order['remark']}"></td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <div class="portlet box green">
                                        <div class="portlet-title">
                                            <div class="caption"><i class="fa fa-gift"></i>地图</div>

                                        </div>
                                        <div id="container"></div>
                                        <div id="info" style="margin-top:10px;display: none">
                                            <button id="mapM" type="button" class="btn">setMap</button>
                                            <button id="cable" type="button" class="btn">setClickable</button>
                                            <button id="drag" type="button" class="btn">setDraggable</button>
                                            <button id="visibleF" type="button" class="btn">setVisible</button>
                                            <button id="setP" type="button" class="btn">setPosition</button>
                                        </div>
                                </div>
                                <!--客户要求调整的位置-->
                                    <div class="portlet box blue">

                                        <div class="portlet-title">

                                            <div class="caption"><i class="fa fa-gift"></i>费用信息</div>

                                            <div class="tools">
                                                <a href="javascript:;" class="collapse"></a>
                                                <a href="#portlet-config" data-toggle="modal" class="config"></a>
                                                <a href="javascript:;" class="reload"></a>
                                                <a href="javascript:;" class="remove"></a>
                                            </div>

                                        </div>
                                        <div class="portlet-body">
                                        <div class="table-responsive">
                                            <table class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>预付款</th>
                                            <th>尾款</th>
                                            <th>总价</th>
                                            <th>计算</th>
                                            <th>公里</th>
                                            
                                        </tr>
                                        <tr>
                                            <td  class="danger"> <input type="text" name="advance_price" id='advance_price' value='50'></td>
                                            <td  class="danger"> <input type="text" name="small_balance" id='small_balance' value=''></td>
                                            <td  class="success"> <input type="text" name="total_price" id='total_price' value=''></td>
                                            <td  class="success"><button type="button" id='amount'>计算价格</button></td>
                                            <td ><input type="text" name="mile" id="mile" value='0'></td>
                                            
                                        </tr>
                                        <tr>
                                            <th>起价费</th>
                                            <th>用车费用总计</th>
                                            <th>搬入楼层费</th>
                                            <th>搬出楼层费</th>
                                            <th>超公里费用(￥{$cartypeInfo.over_charge})/公里</th>
                                            <th>大件费用</th>
                                            <th>平地搬运费用</th>
                                            <th>有无大件（家具家电）</th>
                                        </tr>
                                        <tr>
                                            <td  class="success"><input type="text" name="flag_fall_price" id='flag_fall_price' value='{$cartypeInfo.flag_fall_price}'></td>
                                            <td  class="warning"><input type="text" name="cartypeInfo_price" id='cartypeInfo_price' value='300'></td>
                                            <td  class="success"><input type="text" name="floor_from_cost" id='floor_from_cost' value='0'></td>
                                            <td  class="success"> <input type="text" name="floor_to_cost" id="floor_to_cost" value='0'></td>
                                            <td  class="warning"><input type="text"  name='mile_price' id='mile_price' value='0'></td>
                                            <td ><input type="text" name="attachment_price" id='attachment_price' value='0' readonly></td>
                                            <td  class="warning"> <input type="text" name="move_price" id='move_price' value='0'></td>
                                            <td  class="warning"> <input type="text" name="extra_price" id='extra_price' value='0'></td>
                                            <!-- 超公里价格/公里 -->
                                            <input type="hidden" name="over_charge" id='over_charge' value='{$cartypeInfo.over_charge}'>
                                        </tr>
                                        <!--客户要求调整的位置-->
                                            <tr>
                                                <th>附加项目</th>
                                                <th>规格</th>
                                                <th>单价</th>
                                                <th>数量</th>
                                                <th>费用合计</th>
                                                <!-- <if  condition="$key eq 0"><th colspan="2">附加项目合计</th></if> -->
                                            </tr>
                                        <volist name="attachment.list" id="item">
                                            <tr>
                                                <td>{$item.attachment_title}</td>
                                                <td>{$item.option}</td>
                                                <td>{$item.value}</td>
                                                <td>{$item.num}</td>
                                                <td class="success">{$item.price}</td>
                                                <!-- <if  condition="$key eq 0"><td  class="warning" rowspan="{:(count($attachment['list'])*2-1)}" colspan="2">{$attachment.price}</td></if> -->
                                            </tr>
                                        </volist>
                                        <notempty name='order.refund_price'>
                                        <tr>
                                            <th>退款金额</th>
                                            <th>退款单号</th>
                                        </tr>
                                        <tr>
                                            <td class="danger">{$order.refund_price}</td>
                                            <td class="danger">{$order.refund_no}</td>
                                        </tr>
                                        </notempty>
                                    </thead>
                                </table>
                                 </div>
                                </div>
                            </div>

                       
                         

                         <div class="portlet box blue">

                                <div class="portlet-title">

                                    <div class="caption"><i class="fa fa-gift"></i>其他费用</div>

                                    <div class="tools">

                                        <a href="javascript:;" class="collapse"></a>

                                        <a href="#portlet-config" data-toggle="modal" class="config"></a>

                                        <a href="javascript:;" class="reload"></a>

                                        <a href="javascript:;" class="remove"></a>

                                    </div>

                                </div>

                                <div class="portlet-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered table-advance table-hover">
                                            <thead>
                                                <foreach name='attachmentList' item='atta' key="index">
                                                    <tr>
                                                        <th align="center">{$atta.title}</th>
                                                        <foreach name='atta.child' item='item' key='key'>
                                                            <td align="left">{$item.option}【{$item.value}】
                                                                <if condition="($item['value'] neq 0) and ($item['value'] neq -1)">
                                                                <button type="button" class="mus" data-key='{$key}' data-index="{$index}">-</button>
                                                                <input type="" name="num" value="{$item.num}" style="width:20px" disabled>
                                                                <button type="button" class="add" data-key='{$key}' data-index="{$index}">+</button>
                                                                </if>
                                                            </td>
                                                        </foreach>
                                                    </tr>
                                                </foreach>

                                            </thead>

                                        </table>

                                    </div>

                                </div>
                                <input type="hidden" name="attachment" value="" id="attachment">

                            </div>
                            <script type="text/javascript">
                                console.log('开始了')
                                var attachment=eval(<php>echo json_encode($attachmentList);</php>);//规格属性
                                var data = [];
                                $('.add').click(function(){
                                    var key = $(this).data('key');
                                    var index = $(this).data('index');
                                    console.log('父'+index+'子'+key)
                                    ++attachment[index]['child'][key]['num'];
                                    console.log(attachment[index]['child'][key]);

                                    var price =Number(attachment[index]['child'][key]['value'])+Number($('#attachment_price').val());//合计大件价格
                                    $('#attachment_price').val(price);//重新赋值
                                    
                                    var num =Number($(this).prev().val())+1;
                                    $(this).prev().val(num);
                                    $('#attachment').val(JSON.stringify(attachment));
                                })
                                $('.mus').click(function(){
                                    var key = $(this).data('key');
                                    var index = $(this).data('index');
                                    console.log('父'+index+'子'+key)
                                    if(attachment[index]['child'][key]['num']>0){
                                      --attachment[index]['child'][key]['num']; 
                                        var num =Number($(this).next().val())-1;
                                        $(this).next().val(num);

                                        var price = Number($('#attachment_price').val()) - Number(attachment[index]['child'][key]['value']);//合计大件价格
                                        $('#attachment_price').val(price);//重新赋值
                                    }
                                    // console.log(attachment[index]['child'][key]);
                                    // console.log(attachment);
                                    $('#attachment').val(JSON.stringify(attachment));
                                })
                                // console.log(attachment)
                            </script>
                         

                                <div class="form-actions top fluid ">

                            <div class="col-md-offset-3 col-md-9">

                               <!--  <if condition="$order['status'] eq 1 or $order['status'] eq 2">


                                </if> -->
                                <button class="btn green" type="submit"  href="#basic">点击下单</button>

                                <button class="btn default" type="button" id="cancel" onclick="history.go(-1)">返回</button>

                            </div>

                        </div>



                            </div>

                        </div>



                    </form>

                    <!-- END FORM-->

                </div>

            </div>

            <!-- END EXAMPLE TABLE PORTLET-->

        </div>

    </div>

    <!-- END PAGE CONTENT -->

</div>

<div id="img_preview" class="modal fade modal-scroll" tabindex="-1" data-replace="true" style="display: none;" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>

                <h4 class="modal-title">图片预览</h4>

            </div>

            <div class="modal-body">

                <img id="preview" style="width: 540px" alt="" src="">

            </div>

            <div class="modal-footer">

                <button type="button" data-dismiss="modal" class="btn green">Close</button>

            </div>

        </div>

    </div>

</div>

<!-- END CONTAINER -->

<!-- BEGIN FOOTER -->

<include file="Inc/foot"/>

<!-- END FOOTER -->

<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->



<!-- END CORE PLUGINS -->

<!-- BEGIN PAGE LEVEL SCRIPTS -->

<script src="__JS__/app.js" type="text/javascript"></script>

<script src="__JS__/form-components.js"></script>

<script src="__JS__/controllers/new/edit.js" type="text/javascript"></script>

<!-- END PAGE LEVEL SCRIPTS -->

<script>
    jQuery(document).ready(function() {

        App.init(); // initlayout and core plugins

        FormComponents.init();

    });

    //初始与目的地实时获取关键词
    var markersInitArray = [
        // {Lat: 41.820138, Lng: 123.41991, id: 1, content: ''},
        // {Lat: 41.820138, Lng: 123.41991, id: 2, content: ''},
        // {Lat: 40.9982978489732, Lng: 117.92939186096191, id: 3, content: '3333'},
    ];
    start_lat=''
    start_lng=''
    end_lat=''
    end_lng=''
    //出发点选中
    function inputSelect(){
        console.log('选中了datalist')
        var input_select=$("#departure").val();
        var option_length=$(".dep").length;
        var option_id='';
        for(var i=0;i<option_length;i++){
         var option_value=$(".dep").eq(i).attr('data-value');
         console.log(option_value)
         if(input_select==option_value){
             lng=$(".dep").eq(i).attr('data-lng');
             lat=$(".dep").eq(i).attr('data-lat');
             start_lat = lat
             start_lng = lng
             markersInitArray[0]={Lat: lat, Lng: lng, id: 1, content: '起点'};
             init()
             if(start_lng!='' && start_lat!='' && end_lat!='' && end_lng!=''){
                console.log('开始规划')
                line(start_lat,start_lng,end_lat,end_lng)
            }
             break;
         }
        }
    }
    //终点选中
    function ainputSelect(){
        console.log('选中了datalist')
        var input_select=$("#arrival").val();
        var option_length=$(".arr").length;
        var option_id='';
        for(var i=0;i<option_length;i++){
             var option_value=$(".arr").eq(i).attr('data-value');
             console.log(option_value)
             if(input_select==option_value){
                lng=$(".arr").eq(i).attr('data-lng');
                lat=$(".arr").eq(i).attr('data-lat');
                end_lat = lat
                end_lng = lng
                markersInitArray[1]={Lat: lat, Lng: lng, id: 2, content: '终点'}
                init();//地图初始化
                console.log(start_lng,start_lat,end_lat,end_lng)
                if(start_lng!='' && start_lat!='' && end_lat!='' && end_lng!=''){
                    console.log('开始规划')
                    line(start_lat,start_lng,end_lat,end_lng)
                }
                break;
            }
        }
    }

    coors=[];
    //路线规划
    function line(start_lat,start_lng,end_lat,end_lng){
        $.ajax({
            type:"POST",
            url:"{:U('Map/line')}",
            data: {'start_lat':start_lat,'start_lng':start_lng,'end_lat':end_lat,'end_lng':end_lng}, 
            success:function (res){
                console.log('路线规划回调');
                
                if(res.status==1){
                    //解压
                    // console.log('未解压');
                    // console.log(res.data);
                    var coors=res.data;
                    // var lineNew=[];
                    for (var i = 2; i < coors.length; i++){
                        coors[i] = coors[i-2] + coors[i]/1000000
                    }
                    // console.log('已解压');
                    // console.log(coors)
                    path=[];
                    for(var j = 0;j<coors.length;j++){
                        var p = new qq.maps.LatLng(coors[j],coors[j+1]);
                        path.push(p);
                        j++;
                    }

                    var polyline = new qq.maps.Polyline({
                        path: path,
                        strokeColor: '#DC143C',
                        strokeWeight: 5,
                        editable:false,
                        map: map
                    });
                    console.log(res.mile);
                    $('#mile').val(res.mile);
                    if(res.mile>10){
                        var cha = res.mile-10;
                        var flag_fall_price = $('#flag_fall_price').val();//起价费
                        var over = Number($('#over_charge').val()) * cha;//超出公里所有价格
                        $('#mile_price').val(over);
                        var all = Number(flag_fall_price)+over//用车费用总计=起价+超出公里费用
                        $('#cartypeInfo_price').val(all);

                    }
                    
                }
            }
        });
    }

    $('#departure').bind('input propertychange', function() {
        console.log($(this).val());
        var key=$(this).val();
        $.ajax({
            type:"GET",
            url:"{:U('Map/keyword')}",
            data: {'key':key}, 
            success:function (res){
                if(res.status==1){
                    var data = res.data;
                    console.log(data);
                    var str='';
                    for(var i=0;i<data.length;i++){
                        str+="<option class='dep' data-lng="+data[i]['location']['lng']+" data-lat="+data[i]['location']['lat']+" value="+data[i]['title']+'-'+data[i]['address']+" data-value="+data[i]['title']+'-'+data[i]['address']+">";
                    }
                    $('#departurelist').html(str);
                    
                }
            }
        });

    }); 
    $('#arrival').bind('input propertychange', function() {
        console.log($(this).val());
        var key=$(this).val();
        $.ajax({
            type:"GET",
            url:"{:U('Map/keyword')}",
            data: {'key':key}, 
            success:function (res){
                if(res.status==1){
                    var data = res.data;
                    console.log(data);
                    var str='';
                    for(var i=0;i<data.length;i++){
                        str+="<option class='arr' data-lng="+data[i]['location']['lng']+" data-lat="+data[i]['location']['lat']+" value="+data[i]['title']+'-'+data[i]['address']+" data-value="+data[i]['title']+'-'+data[i]['address']+">";
                    }
                    $('#arrivallist').html(str);
                    // end = data.
                    
                }
            }
        });
    }); 

    
    //全部金额计算
    $('#amount').click(function(){
        if($('#flag_fall_price').val()=='' || $('#cartypeInfo_price').val()=='' || $('#floor_from_cost').val()=='' || $('#floor_to_cost').val()=='' || $('#over_charge').val()=='' || $('#attachment_price').val()=='' || $('#move_price').val()=='' || $('#extra_price').val()==''){
            layer.alert('部分金额请正确填写');return false;
        }
        var cartypeInfo_price = $('#cartypeInfo_price').val();//用车总价
        var floor_from_cost = $('#floor_from_cost').val();
        var floor_to_cost = $('#floor_to_cost').val();
        var attachment_price = $('#attachment_price').val();
        var move_price = $('#move_price').val();
        var extra_price = $('#extra_price').val();
        var total_price = Number(cartypeInfo_price)+Number(floor_from_cost)+Number(floor_to_cost)+Number(attachment_price)+Number(move_price)+Number(extra_price);
        var small_balance = Number(total_price)-Number($('#advance_price').val());
        $('#total_price').val(total_price);
        $('#small_balance').val(small_balance);

    })

    //楼层选择
    function to_change(){
        var price = $('#floor_to').find("option:selected").attr("price");
        console.log(price)
        $('#floor_to_cost').val(price);
    }

    function from_change(){
        var price = $('#floor_from').find("option:selected").attr("price");
        console.log(price)
        $('#floor_from_cost').val(price);
    }

    $(function(){
        init();//地图初始化
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#addtime', //指定元素
                type:'datetime'
            });
            laydate.render({
                elem: '#booktime', //指定元素
                type:'datetime'
            });
        });
    })

    var Lat, Lng, latLng, selectIndexPoint, selectIndexPoints, map;
    var count = 1;
    var arr_idx = 0;
    var pointInfo = String; 
    // 初始化标注点数组
     
    var [pointArr, latlngs, markersArray, markersArrays, pointArrcopy, markersInitArrays] = [[], [], [], [], [], []];
    markersInitArrays = markersInitArray
    //地图中心点
    var center = new qq.maps.LatLng(41.820138,123.419914);
    var init = function() {
        map = new qq.maps.Map(document.getElementById("container"),{
            center: center,
            zoom: 12
        });
        // 初始化标记点
        if(markersInitArray.length>0){
            initMarker(markersInitArray)
        }
        //绑定单击事件添加参数
        qq.maps.event.addListener(map, 'click', function(event) {
            Lat = event.latLng.getLat();
            Lng = event.latLng.getLng();
            if($('.alerts').hasClass('bounceIn')){
                console.log("bounceIn");
            }else{
                $('.alerts').addClass('bounceIn')
            }
            $('.cancles').click(function(){
                $('.alerts').removeClass("bounceIn");
            })
            var confirm = document.getElementById("confirm")
            qq.maps.event.addListener(confirm, 'click', function(event) {
                var iptValue = $("#ipts").val()
                var arr = []
                latLng = {
                    Lat: Lat,
                    Lng: Lng,
                    content: iptValue
                }
                arr.push(latLng);
                pointArr = pointArr.concat(arr)
                console.log("latLng", latLng);
                // pointArr = arr.push(latLng);
                console.log("pointArr", pointArr);
                var marker = new qq.maps.Marker({
                    position: new qq.maps.LatLng(latLng.Lat, latLng.Lng),
                    map: map
                });
                markersArray.push(marker)
                // $("#ipts").val("")
                console.log(pointArr);
                qq.maps.event.addListener(marker, 'click', function(e) {
                    pointArr.map((item, index) =>{
                        if(pointArr[index].Lat == e.latLng.getLat() && pointArr[index].Lng == e.latLng.getLng()){
                            selectIndexPoint = index
                        }
                    })
                    console.log("当前选中的坐标索引值", selectIndexPoint)
                    console.log("当前的坐标数组", pointArr)
                    markersArray[selectIndexPoint].setMap(null)
                    pointArr.splice(selectIndexPoint, 1)
                    markersArray.splice(selectIndexPoint, 1)
                    console.log("删除之后的坐标数组", pointArr)
                }); 
                $('.alerts').removeClass("bounceIn")
            })
            count++
        });
    }

    function initMarker(arr){
        var initarr = []
        for (let prop of arr) {
            initarr.push('new qq.maps.LatLng('+prop.Lat+','+prop.Lng+')');
        }
        console.log(arr);
        for(var i = 0;i < initarr.length; i++) {
            (function(n){
                console.log(n)
                var markers = new qq.maps.Marker({
                    position: eval(initarr[n]),
                    map: map
                });
                if(arr[n]['content']!=''){
                    var label = new qq.maps.Label({
                        position: eval(initarr[n]),
                        map: map,
                        content:arr[n]['content']
                    });
                }

                markersArrays.push(markers)
                qq.maps.event.addListener(markers, 'click', function(e) {
                    $('.alert').addClass('bounceIn')
                    var selectindex;
                    selectindex = arr.findIndex(item=>{
                        return item.lat == e.latLng.getLat()
                    })
                    // arr.map((item, index) =>{
                    //  if(arr[index].Lat == e.latLng.getLat()){
                    //      selectindex = index
                    //  }
                    // })
                    // $('#ipt').val(arr[selectindex].content)
                    console.log("selectindex", selectindex)
                    // var ok = document.getElementById("confirm")
                    // qq.maps.event.addListener(ok, 'click', function(event) {
                    //     arr[selectindex].content = $('#ipt').val();
                    //     console.log(arr);
                    //     deleteAllOverlays()
                    //     $('.alert').removeClass("bounceIn")
                    //     initMarker(arr)
                    // })
                    // var del = document.getElementById("cancle")
                    // qq.maps.event.addListener(del, 'click', function(event) {
                    //     console.log("初始化当前选中的坐标索引值", selectindex)
                    //     for (i in markersArrays) {
                    //         markersArrays[selectindex].setMap(null);
                    //     }
                    //     markersArrays.splice(selectindex, 1)
                    //     arr.splice(selectindex, 1)
                    //     console.log("删除之后的坐标数组", arr)
                    //     $('.alert').removeClass("bounceIn")
                    // })
                })
            })(i)
        }
    }
</script>

<script language="javascript">



    function findNext(v , e , dom){

        var selValue = parseInt(v);

        var areaNextId = parseInt(e+1);

        $("#"+dom+"_"+areaNextId).remove();

        $("#"+dom+"_"+e+" > select > option").each(function(i){

            if($(this).attr('value') == v){

                $(this).attr('selected',true);

            }

        });





        var data = { r: Math.random(),selValue: selValue,areaNextId: areaNextId ,domId: dom};

        $.ajax({type:"GET", url:"<php>echo U('Order/ajaxFindNext');</php>",data: data, dataType:"text",async:false,success:function (msg){

        r = msg;

        }});

    if (r==0) {

        return false;

    } else {

        r='<div class="radio-inline">'+r+'</div>';

        $('#'+dom+'_'+e).append(r);

        return true;

    }





    }



    $(function(){

        {$content}

    });



</script>

</body>

<!-- END BODY -->

</html>